import { defineStore } from 'pinia'  //npm install pinia

export const useUserStore = defineStore('user', {
  state: () => ({
    user: null, // 初始用户数据
  }),
  actions: {
    // 存储用户信息
    setUser(userData) {
      this.user = userData
    },
    // 清除用户信息
    clearUser() {
      this.user = null
    },
  },
  getters: {
    // 获取用户信息
    getUser: (state) => state.user,
  },
})